package club.vann.kafka.mock.service.transfer;

import club.vann.kafka.mock.kafka.KafkaProducer;
import club.vann.kafka.mock.kafka.KafkaTopicFactory;
import com.cyberx.lunyu.TransferInfoOuterClass;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
public class TransferService {
  private final KafkaProducer kafkaProducer;

  public void transfer() {
    TransferInfoOuterClass.TransferInfo transferInfo =
        TransferInfoOuterClass.TransferInfo.newBuilder()
            .setClientId("CLIENT_ID")
            .setSourceExchange("SOURCE_EXCHANGE")
            .setSourceAccount("SOURCE_ACCOUNT")
            .setDestExchange("DEST_EXCHANGE")
            .setDestAccount("DEST_ACCOUNT")
            .setAmount(100)
            .setCurrency("USDT")
            .setStatus("NEW")
            .build();
    this.kafkaProducer.send(
        KafkaTopicFactory.TRANSFER_OUTPUT, transferInfo.getCurrency(), transferInfo.toByteArray());
  }
}
